package com.strange.mdl.module.mdl.dal.mysql.sutras;

import com.strange.mdl.framework.common.pojo.PageResult;
import com.strange.mdl.framework.mybatis.core.mapper.BaseMapperX;
import com.strange.mdl.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.strange.mdl.module.mdl.controller.admin.sutras.vo.volumes.MdlSutraVolumesPageReqVO;
import com.strange.mdl.module.mdl.dal.dataobject.sutras.MdlSutraVolumesDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 经书卷 Mapper
 *
 * @author 密谛灵总控
 */
@Mapper
public interface MdlSutraVolumesMapper extends BaseMapperX<MdlSutraVolumesDO> {

    default PageResult<MdlSutraVolumesDO> selectPage(MdlSutraVolumesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MdlSutraVolumesDO>()
                .eqIfPresent(MdlSutraVolumesDO::getSutraId, reqVO.getSutraId())
                .eqIfPresent(MdlSutraVolumesDO::getVolumeNumber, reqVO.getVolumeNumber())
                .eqIfPresent(MdlSutraVolumesDO::getVolumeTitle, reqVO.getVolumeTitle())
                .betweenIfPresent(MdlSutraVolumesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MdlSutraVolumesDO::getId));
    }


    default List<MdlSutraVolumesDO> selectList(Long sutraId) {
        return selectList(new LambdaQueryWrapperX<MdlSutraVolumesDO>()
                .eqIfPresent(MdlSutraVolumesDO::getSutraId, sutraId)
                .orderByDesc(MdlSutraVolumesDO::getVolumeNumber));
    }
}
